#include <stdio.h>
#include <stdlib.h>
#include "camellia.h"
#include <time.h>
#include <inttypes.h>
int64_t timespecDiff(struct timespec *timeA_p, struct timespec *timeB_p)
{
	  return ((timeA_p->tv_sec * 1000000000) + timeA_p->tv_nsec) -
	             ((timeB_p->tv_sec * 1000000000) + timeB_p->tv_nsec);
}
int main(int argc, char* argv[])
{
	struct timespec start, end;
	CamImage source, zoom2xImage;
	camLoadPGM(&source, argv[1]);
	camAllocateImage(&zoom2xImage, source.width*2, source.height*2, source.depth);

	time_t beg = time(NULL);
	int i;
	const int iterations = 100;
	clock_gettime(CLOCK_MONOTONIC, &start);
	for(i = 0; i < iterations; i++)
		camZoom2x(&source, &zoom2xImage);
	clock_gettime(CLOCK_MONOTONIC, &end);
	uint64_t timeElapsed = timespecDiff(&end, &start);
	printf("%llu seconds for %d iterations\n", (unsigned long long) timeElapsed, iterations);

	camSavePGM(&zoom2xImage, argv[2]);
}
